//
//  StatusCell.swift
//  sinaBlog
//
//  Created by tianxiangyang on 15/12/18.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

import UIKit
import SnapKit
class StatusCell: UITableViewCell {

    
    var status:BlogStatus?{
        didSet{
       topView.status = status
            
    retweetedView.retweentedStatus = status?.retweeted_status
            

        }
    }
    //不会调用
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setupUI()
        
        //取消点击cell的高亮效果
        
        self.selectionStyle = UITableViewCellSelectionStyle.None
        
        
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK:设置界面
    private func setupUI(){
    
        contentView.addSubview(topView)
        contentView.addSubview(bottomView)
        contentView.addSubview(retweetedView)

        topView.snp_makeConstraints { (make) -> Void in
          
            make.top.left.right.equalTo(contentView)
                 
        }
        
        

        
        retweetedView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(topView.snp_bottom).offset(statusMargin)
            make.left.right.equalTo(topView)
//            make.height.equalTo(150)
        }
        
        
        
        
        bottomView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedView.snp_bottom)
            make.left.right.equalTo(contentView)
            make.height.equalTo(statusBottomViewHeight)
        }
        
    
        //设置contentView的约束
        
        contentView.snp_makeConstraints { (make) -> Void in
        make.top.left.right.equalTo(self)
        make.bottom.equalTo(bottomView.snp_bottom).offset(statusMargin)
            
        }
        
        
    }
    
    //MARK:懒加载视图控件
    private lazy var topView:StatusCellTopView = StatusCellTopView()
    private lazy var bottomView:StatusBottomView = StatusBottomView()
    private lazy var retweetedView:StatusRetweetedView = StatusRetweetedView()
    
}
